#ifndef HASHER_H_
#define HASHER_H_

#include <limits>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <limits>

using namespace std;

class Hasher {
public:
	static unsigned long long abcHash(std::string word) {
		unsigned long long MAX_VALUE = numeric_limits<unsigned long long>::max();
		unsigned long long hash = 0;
		for (uint i = 0; i<word.size(); i++)
			hash = (hash + (unsigned long long)( (tolower(word[i]) - 'a' + 1)*pow(27,i)) )%MAX_VALUE;
		return hash;
	}
	
	static std::string reverseAbcHash(unsigned long long hash) {
		std::string word = "";
		std::vector<char> letters;
		short division = 1; //!= 0
		short numLetras = short(log(hash)/log(27));
//		cout << "l: " << log(hash)/log(26) << endl;
//		cout << "n: " << numLetras << endl;
		while (numLetras >= 0) {
			division = short (hash / ( pow(27,numLetras) ) );
			letters.push_back(char(division + 'a' - 1));
			hash = hash%( (unsigned long long)( pow(27, numLetras) ) );
			numLetras--;
		}
		std::vector<char>::reverse_iterator it;
		for (it = letters.rbegin(); it != letters.rend(); it++)
			word += *it;
		return word;
	}
};

#endif /*HASHER_H_*/
